#pragma once

#include"SpendType.h"

namespace Macro
{
	class Resource
	{
	public:
		Resource(Player* player)
			:_mineral(player->minerals()),
			_gas(player->gas())
		{
		}
		inline void Tick()
		{
			_mineral += _incomeOfMineral;
			_gas += _incomeOfGas;
		}
		inline void Set(const int& mineral , const int& gas)
		{
			_mineral = mineral;
			_gas = gas;
		}
		inline void SetAmountOfHarvestingWorkers(const int& amountOfMiningWorker , const int& amountOfgasingWorker)
		{
			_incomeOfMineral = MINERAL_RATE_PER_DRONE * (float)amountOfMiningWorker;
			_incomeOfGas = GAS_RATE_PER_DRONE * (float)amountOfgasingWorker;
		}
		inline bool NoGasingWorker() const
		{
			return _incomeOfGas <= 0.0001;
		}
		inline const int Mineral() const
		{
			return (int)_mineral;
		}
		inline const int Gas() const
		{
			return (int)_gas;
		}
		inline const float MineralIncome() const
		{
			return _incomeOfMineral;
		}
		inline bool AllowSpend(const SpendType& spendType)
		{
			return MineralPrice(spendType) <= Mineral() && GasPrice(spendType) <= Gas();
		}
		inline void Spend(const SpendType& spendType)
		{
			_mineral -= MineralPrice(spendType);
			_gas -= GasPrice(spendType);
		}
		//--
		const static float MINERAL_RATE_PER_DRONE;
		const static float GAS_RATE_PER_DRONE;
	private:
		float _mineral;
		float _gas;
		float _incomeOfMineral;
		float _incomeOfGas;
	};
	const float Resource::MINERAL_RATE_PER_DRONE = 0.05f;
	const float Resource::GAS_RATE_PER_DRONE = 0.07f;
}